<?php
/**
 *+------------------
 * Lflow
 *+------------------
 * Copyright (c) 2023~2030 gitee.com/liu_guan_qing All rights reserved.本版权不可删除，侵权必究
 *+------------------
 * Author: Mr.April(405784684@qq.com)
 *+------------------
 */
declare (strict_types=1);

namespace lflow\entity;

trait Common
{

    /**
     * 写入属性
     *
     * @param string $name
     * @param        $value
     */
    public function set(string $name, $value)
    {
        $this->{$name} = $value;
    }

    /**
     * 获取属性
     *
     * @param string $name
     *
     * @return string
     */
    public function get(string $name)
    {
        return $this->{$name} ?? '';
    }

    /**
     * @return string
     */
    public function toString(): string
    {
        return json_encode(get_object_vars($this));

    }

    /**
     * @return array
     */
    public function toArray(): array
    {
        return get_object_vars($this);
    }

}